/*===========================================================================
Project:       Data Analysis. Considering Concessions: A Survey Experiment on the Colombian Peace Process
Author:        Aila Matanock and Natalia Garbiras Diaz 
Dependencies:  UC Berkeley
---------------------------------------------------------------------------
Creation Date:       August 7, 2015 
Modification Date:  July 10, 2018
Do-file version:    08
References:          
Output:             Tex file - Graphs - Other
===========================================================================*/

/*===============================================================================================
                                  0: Program set up
===============================================================================================*/

drop _all

* Directory Paths
global root        "/Data"
global dta_out     "/Clean_data"
global results     "/Results"


/*===============================================================================================
                                  1: Data cleaning
===============================================================================================*/

/* (Data available at: https://obsdemocracia.org/temas-de-estudio/datos/
"Muestra Especial Zonas Conflicto Bar�metro de las Americas 2015") */

use "$root/Colombia_Muestra_Especial_2015.dta", clear

* Recode missing variables 
recode COLPRIME1TA1 COLPRIME1TA2 COLPRIME1TB1 COLPRIME1TB2 COLPRIME2TA1 ///
COLPRIME2TA2 COLPRIME2TB1 COLPRIME2TB2 COLENDORS1CA1 COLENDORS1TA2 COLENDORS1CB1 ///
B18 B12 B20 COLPROPAZ1 COLB60 B21A B13 COLPAZ1A COLCONCE7 COLCONCE2 COLCONCE1 COLCONCE4 COLCONCE5 ///
COLENDORS1TB2 (8/9=.) (99 = .i)

recode L1 (11/12=.)

* Bring all variables to lower case 
rename *, lower

*------------------------------------1.1: Treatment variables ------------------------------------

gen prime = (colprime1ta1!= .i) | (colprime1ta2 != .i)
lab var prime "Prime treatment" 
gen endors = (colendors1ta2 != .i) | (colendors1tb2  != .i)
lab var endors "Endorsement experiment"

lab def yesno 0"No" 1"Yes"
lab val prime endors yesno

* Table 1
tabout prime endors using "$results/matrix_treats.tex", ///
cells(freq cell) format(0 1) clab(No. Cell_%) ///
replace ///
style(tex) bt cl1(2-7) cl2(2-3 4-5 6-7) font(bold) ///
topf("$results/top.tex") botf("$results/bot.tex") topstr(14cm) botstr(Authors calculations)

gen treatment = 1 if prime == 1 & endors == 0
replace treatment = 2 if prime == 1 & endors == 1
replace treatment = 3 if prime == 0 & endors == 0
replace treatment = 4 if prime == 0 & endors == 1
lab var treatment "Experimental Group"
lab def treatment 1"Prime treat. Endor. ctrl." 2"Prime treat. Endors. treat." ///
		3"Prime ctrl. Endors. ctrl." 4"Prime ctrl. Endors. treat."
lab val treatment treatment 

*------------------------------------1.2: Outcomes only prime ------------------------------------

/* Colprime1: Que se creen curules especiales en el Congreso para partidos pol�ticos 
              formados por desmovilizados de las FARC. �Hasta qu� punto est� de acuerdo o en desacuerdo?
   Colprime2: Que una vez se desmovilicen, las FARC formen un partido pol�tico para lograr obtener cargos en 
              el Congreso mediante elecciones populares. �Hasta qu� punto est� de acuerdo o en desacuerdo?
   COLENDORS: [Algunas personas/Las FARC] han propuesto reservar curules del Congreso para las regiones m�s afectadas 
              por el conflicto armado, con el fin de que estas regiones tengan mayor representaci�n en el Congreso. 
			  �Hasta qu� punto est� de acuerdo o en desacuerdo?	

Other outcomes:

	COLESPA6. Si en las pr�ximas elecciones locales, es decir las de 2015, un desmovilizado de las FARC se 
			  presenta como candidato a la alcald�a de su municipio, �qu� har�a usted?
	COLESPA8. Si en las pr�ximas elecciones locales, es decir las de 2015, un desmovilizado de las FARC 
	          gana la alcald�a de su municipio, �qu� har�a usted?

*/ 
gen y_1 = .
replace y_1 = colprime1ta1 if prime == 1 & endors == 0 
replace y_1 = colprime1ta2 if prime == 1 & endors == 1 
replace y_1 = colprime1tb1 if prime == 0 & endors == 0 
replace y_1 = colprime1tb2 if prime == 0 & endors == 1 
lab var y_1 "Obs. outcome Comprime1"

gen y_2 = .
replace y_2 = colprime2ta1 if prime == 1 & endors == 0 
replace y_2 = colprime2ta2 if prime == 1 & endors == 1 
replace y_2 = colprime2tb1 if prime == 0 & endors == 0 
replace y_2 = colprime2tb2 if prime == 0 & endors == 1 
lab var y_2 "Obs. outcome Comprime2"

gen y_4 = (colespa6 == 1)
lab def y_4 0"Would not vote" 1"Would vote"
lab val  y_4 y_4
lab var y_4 "Obs. outcome Colespa6"

gen y_5 = (colespa8 == 1)
lab def y_5 0"Would not accept" 1"Accepts"
lab val  y_5 y_5
lab var y_5 "Obs. outcome Colespa8"

gen y_3 = .
replace y_3 = colendors1ca1 if prime == 1 & endors == 0
replace y_3 = colendors1ta2 if prime == 1 & endors == 1
replace y_3 = colendors1cb1 if prime == 0 & endors == 0
replace y_3 = colendors1tb2 if prime == 0 & endors == 1
lab var y_3 "Average support by experimental group"

*------------------------------------1.3: Balance ------------------------------------

* Prepare new varaibles

** Income Quintiles

ssc install sumdist, all replace
set more off
qui gen quintall=.
qui gen wealthscores=.

pca r1 r3 r4 r4a r5 r6 r7 r8 r12 r14 r15 r16 r18 r26 if ur==1
predict  f1u if ur==1
sumdist f1u,  n(5) qgp(quintu)
replace quintall=quintu if ur==1
replace wealthscores=f1u if ur==1

pca r1 r3 r4 r4a r5 r6 r7 r8 r12 r14 r15 r16 r18 r26 if ur==2
predict  f1r if ur==2
sumdist f1r,  n(5) qgp(quintr)
replace quintall=quintr if ur==2
replace wealthscores=f1r if ur==2

drop f1*u  f1*r quint*u quint*r wealthscores
label variable quintall "Income Quintiles"

** Age 
capture drop edad
g q2=2014-q2y
recode q2 (16/25=1 "18-25")(26/35=2 "26-35") (36/45=3 "36-45") (46/55=4 "46-55") (56/65=5 "56-65")(66/max =6 "66+"), g(edad)
tab edad, g(age)
label variable edad "Age"
la var age1 "18-25"
la var age2 "26-35"
la var age3 "36-45"
la var age4 "46-55"
la var age5 "56-65"
la var age6 "66 +"

clonevar sex = q1
recode sex (1=0) (2=1)
lab var sex "Woman"
lab def sex 0"Man" 1"Woman"
lab val sex sex  

clonevar area = ur
recode area (1=0) (2=1)
lab var area "Rural"
lab def area 0 "Urban" 1"Rural"
lab val area area

tabout sex edad quintall area treatment using "$results/balance.tex", replace ///
cells(cell) format(0p) h1(nil) h3(nil) ///
layout(cb) style(tex) bt font(bold) /*rotate(60)*/ ///
topf("$results/top.tex") botf("$results/bot.tex") topstr(14cm) botstr(Authors' calculations)

*------------------------------------1.4: Figure 1 ------------------------------------

* Figure 1: Graph support

graph bar colpropaz1 colb60, scheme(s1mono) title("") ylab(, nogrid) blabel(bar, format(%12.2f)) plotregion(style(none)) ///
	 saving("$results/figure2a", replace)  bargap(80) ylab(1(1)7)/*yscale(off)*/ showyvars legend(off) yvaroptions(relabel(1"Q: Do you support the Peace Process?"  2 "Q: Do you trust the FARC?"))
graph export "$results/figure2a.pdf", replace

*------------------------------------1.5: Figures Appendix ------------------------------------

* Figure 2: Graph trust other insts

* Graph support 2015

graph bar b18 b12 b20 colpropaz1 colb60 y_1 y_2 y_3 b21a b13, scheme(s1mono) ///
 title("2015", size(medium)) ylab(, nogrid) blabel(bar, format(%12.2f)) plotregion(style(none)) ///
	 saving("$results/figure22015", replace)  bargap(80) /*yscale(off)*/ showyvars legend(off)  ///
	 yvaroptions(sort(1) descending relabel(1 "Trust Police" 2 "Trust Military" 3"Trust Catholic Church" 4"Support Peace Process" 5"Trust FARC" 6"Support EPP: Special Seats" 7"Support EPP: Political Party" 8"Support Transitory Circuns." 9"Trust President" 10"Trust Congress") ///
	 label(labsize(vsmall) angle(45)))

* Graph support 2014 (Data available at: http://datasets.americasbarometer.org/database/index.php) 

preserve 
use "$root/1543363879Colombia LAPOP AmericasBarometer 2014_v3.0_W.dta", clear
graph bar b18 b12 b20 colpropaz1 colb60 b21a b13, scheme(s1mono) ///
 title("2014", size(medium)) ylab(, nogrid) blabel(bar, format(%12.2f)) plotregion(style(none)) ///
	 saving("$results/figure22014", replace)  bargap(80) /*yscale(off)*/ showyvars legend(off)  ///
	 yvaroptions(sort(1) descending relabel(1 "Trust Police" 2 "Trust Military" 3"Trust Catholic Church" 4"Support Peace Process" 5"Trust FARC" 6"Trust President" 7"Trust Congress") ///
	 label(labsize(small) angle(45)))
restore 	
 
graph combine "$results/figure22014" "$results/figure22015", scheme(s1mono) rows(2) cols(1) ///
title("", size(medsmall)) 
graph export "$results/figure2_appendix.pdf", replace

* Figure 3: Graph ideology

preserve
	tempfile prior
	use "$root/1543363879Colombia LAPOP AmericasBarometer 2014_v3.0_W.dta", clear
	gen n = 1 
	collapse  (sum) all=n, by(l1)
	drop if l1 ==.
	order  l1 
	keep if l1 < = 10 
	rename l1 l1g
	rename all all0
	save `prior'
restore

preserve
	label def yo 1"Left" 2"2" 3"3" 4"4" 5"5" 6"6" 7"7" 8"8" 9"9" 10"Right"
	lab val l1 yo 
	gen n = 1 
	collapse  (sum) all=n, by(l1)
	drop if l1 ==.
	order  l1
	keep if l1 < = 10 
	rename l1 l1g
	rename all all1
	merge 1:1 l1g using "`prior'"
	graph bar all0 all1, over(l1g) scheme(s1mono) title("") ytitle("Frequency")  ///
	saving("$results/figure3_appendix", replace) legend(label(1 "2014") label(2 "2015"))
	graph export "$results/figure3_appendix.pdf", replace
restore 

* Figure 4: Age and education 2014 and 2015 

preserve
	tempfile prior
	use "$root/1543363879Colombia LAPOP AmericasBarometer 2014_v3.0_W.dta", clear
	cap drop mujer
	gen mujer = (sex==2)
	collapse  (mean) educ=ed (mean) age=q2 (mean) muj=mujer 
	gen year = 2014
	save `prior'
restore

gen ed = edn 
replace ed = 12 if edn == 19
replace ed = 13 if edn == 20
replace ed = 14 if edn == 21
replace ed = 15 if edn == 22
replace ed = .  if edn == 23
lab var ed "Years of education"

preserve
	collapse  (mean) educ=ed (mean) age=q2 (mean) muj=sex 
	gen year = 2015
	append using "`prior'" 	
	graph bar educ, over(year) scheme(s1mono) title("Education") ytitle("Average years of education")  ///
	saving("$results/educ", replace) legend(label(1 "2014") label(2 "2015"))
	graph bar age, over(year) scheme(s1mono) title("Age") ytitle("Average age")  ///
	saving("$results/age", replace) legend(label(1 "2014") label(2 "2015"))
	graph bar muj, over(year) scheme(s1mono) title("Women in sample") ytitle("Proportion women")  ///
	saving("$results/sex", replace) legend(label(1 "2014") label(2 "2015"))
	graph combine "$results/educ" "$results/age" "$results/sex", scheme(s1mono) rows(1) cols(3) ///
	title("", size(medsmall)) 
	graph export "$results/figure4_appendix.pdf", replace
restore 

 
* Figure 5: Graph colpaz1a: 
tab colpaz1a, gen(paz_)
graph bar paz_1 paz_2 paz_3, scheme(s1mono) title("") ytitle("% in each category") ///
		ylab(0(10)100, nogrid) blabel(bar, format(%12.2f)) plotregion(style(none)) per ///
	 saving("$results/figure5_appendix", replace)  bargap(80) /*yscale(off)*/ showyvars legend(off) yvaroptions(relabel(1 "Negotiation" 2 "Use of military force" 3 "Both"))
graph export "$results/figure5_appendix.pdf", replace

 
* Figure 6: Graph attitudes electoral provisions: 

graph bar colconce7 colconce2 colconce1 colconce4 colconce5, scheme(s1mono) ylab(, nogrid) blabel(bar, format(%12.2f)) plotregion(style(none)) ///
	legend(label(1 "Reduced sentences") label(2 "Monetary Aid") label(3 "Transitional Justice") label(4 "Political Participation") label(5 "Political Representation")) ///
	saving("$results/figure6_appendix", replace)  bargap(30) ///
	title("Average support towards different concessions" "from the Government to the FARC")  yscale(off)
graph export "$results/figure6_appendix.pdf", replace

*------------------------------------1.6: Variables analysis type of affectation ------------------------------------

* 1. Victimization 
recode colwc4a (4=.) (99 = .i)
gen farc = (colwc4a == 1)

/*===============================================================================================
                                  2: Data Analysis
===============================================================================================*/

*------------------------------------2.1: Endorsement experiment outcome ------------------------------------

* Interaction with area of residence
gen areaendors = area * endors
lab var areaendors "Rural X Endors."

* Interaction with sex
gen sexendors = sex * endors
lab var sexendors "Woman X Endors."

* Interaction with victimization
gen victim = (wc1 == 1 | wc2 == 1 | wc3 == 1 )
lab var victim "Victim of conflict"
label val victim yesno
gen vicendors = victim * endors
lab var vicendors "Victim X Endors."

gen farc_endors = farc * endors
lab var farc_endors "FARC X Endors."

ttest y_3, by(endors)

** Figure 2a: Graph Results Endorsement Experiment 

quietly eststo Control: mean y_3 if endors==0  
quietly eststo Treatment: mean y_3 if endors==1
coefplot Control Treatment, vertical ///
recast(bar) barwidth(0.25)  ciopts(recast(rcap)) citop citype(normal) ///
graphregion(color(white)) bgcolor(white) ///
ylab(3(0.5)5, nogrid) scheme(s1mono) plotregion(style(none)) mlabel title("") ///
saving("$results/figure2a", replace)
graph export "$results/figure2a.pdf", replace
 
* Figure 2b: Graph y_3 by endorsement experiment condition electoral provisions: 

preserve
	gen n = 1 
	collapse  (sum) all=n, by(y_3 endors)
	drop if y_3 ==.
	order  y_3 endors all
	reshape wide all, i(y_3) j(endors)
	graph bar all1 all0, over(y_3) blabel(bar) scheme(s1mono) title("") ytitle("Frequency")  ///
	ylab(0(20)160, nogrid) plotregion(style(none)) /*yscale(off)*/ ///
	saving("$results/figure2b", replace) legend(label(1 "Treatment Endors. Exp.") label(2 "Control Endors. Exp."))
	graph export "$results/figure2b.pdf", replace
restore

* Table 2

reg y_3 endors, robust
outreg2 using "$results/Endors.tex", label tex(frag) ctitle(Support) replace

reg y_3 endors area areaendors, robust
outreg2 using "$results/Endors.tex", label tex(frag) ctitle(Area) append

reg y_3 endors sex sexendors, robust
outreg2 using "$results/Endors.tex", label tex(frag) ctitle(Sex) append
ttest y_3 if sex == 1, by(endors)

reg y_3 endors victim vicendors, robust
outreg2 using "$results/Endors.tex", label tex(frag) ctitle(Victimization) append

*------------------------------------2.2: T-test prime ------------------------------------

ttest y_1, by(prime)
ttest y_2, by(prime)

* Variables for subgroup analysis: 

gen urprime = area * prime
lab var urprime "Rural X Prime"

gen sexprime = sex * prime
lab var sexprime "Woman X Prime"

gen victprime = victim * prime
lab var victprime "Victim X Prime"

* Table dif in means prime experiment 
reg y_1 prime, robust
outreg2 using "$results/T-test0.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime, robust
outreg2 using "$results/T-test0.tex", label tex(frag) ctitle("FARC Party") append


* Table CATEs for rural
reg y_1 prime area urprime, robust
outreg2 using "$results/CATE_rural.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime area urprime, robust
outreg2 using "$results/CATE_rural.tex", label tex(frag) ctitle("FARC Party")  append

* Table CATEs for sex 
reg y_1 prime sex sexprime, robust
outreg2 using "$results/CATE_woman.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime sex sexprime, robust
outreg2 using "$results/CATE_woman.tex", label tex(frag) ctitle("FARC Party")  append

* Table CATEs for victim 
reg y_1 prime victim victprime, robust
outreg2 using "$results/CATE_victim.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime victim victprime, robust
outreg2 using "$results/CATE_victim.tex", label tex(frag) ctitle("FARC Party")  append

* Test effects by group:
cap mat drop a
loc outcomes y_1 y_2
loc z = 0
foreach var of loc outcomes{
	local ++z
	forvalues i=0(1)1{
		ttest `var' if victim == `i', by(prime)
		loc diff = `r(mu_2)' - `r(mu_1)'
		mat a = nullmat(a) \ `z', `i' , `r(mu_1)', `r(mu_2)', `diff', `r(se)', `r(p)', `r(p_u)' ,`r(p_l)'
} 
}

preserve
	drop _all
	mat colnames a = Outcome Victim Mean0 Mean1 Difference SE_Diff p p_u p_l
	svmat a, n(col)
	lab def Outcome 1"Special seats" 2"Political Party"
	lab val Outcome Outcome
	label define Victim 0"No" 1 "Yes"
	lab val Victim Victim 
	export excel using "$results/Victimization_prime.xlsx", sheetmodify sheet(results) first(varlabel)
restore

* Additional tables for COLESPA6 and COLESPA8 

* Table dif in means
reg y_4 prime, robust
outreg2 using "$results/T-test_add.tex", label tex(frag) ctitle("Vote for FARC Mayor") replace
reg y_5 prime, robust
outreg2 using "$results/T-test_add.tex", label tex(frag) ctitle("Accept FARC Mayor") append

* Table CATEs for rural
reg y_1 prime area urprime, robust
outreg2 using "$results/CATE_rural_add.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime area urprime, robust
outreg2 using "$results/CATE_rural_add.tex", label tex(frag) ctitle("FARC Party")  append
reg y_4 prime area urprime, robust
outreg2 using "$results/CATE_rural_add.tex", label tex(frag) ctitle("Vote for FARC Mayor") append
reg y_5 prime area urprime, robust
outreg2 using "$results/CATE_rural_add.tex", label tex(frag) ctitle("Accept FARC Mayor")  append

* Table CATEs for sex 
reg y_1 prime sex sexprime, robust
outreg2 using "$results/CATE_woman_add.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime sex sexprime, robust
outreg2 using "$results/CATE_woman_add.tex", label tex(frag) ctitle("FARC Party")  append
reg y_4 prime sex sexprime, robust
outreg2 using "$results/CATE_woman_add.tex", label tex(frag) ctitle("Vote for FARC Mayor") append
reg y_5 prime sex sexprime, robust
outreg2 using "$results/CATE_woman_add.tex", label tex(frag) ctitle("Accept FARC Mayor")  append

* Table CATEs for victim 
reg y_1 prime victim victprime, robust
outreg2 using "$results/CATE_victim_add.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime victim victprime, robust
outreg2 using "$results/CATE_victim_add.tex", label tex(frag) ctitle("FARC Party")  append
reg y_4 prime victim victprime, robust
outreg2 using "$results/CATE_victim_add.tex", label tex(frag) ctitle("Vote for FARC Mayor") append
reg y_5 prime victim victprime, robust
outreg2 using "$results/CATE_victim_add.tex", label tex(frag) ctitle("Accept FARC Mayor")  append

* Graphically 
quietly eststo Control0: mean y_1 if prime==0  & victim == 0
quietly eststo Treatment0: mean y_1 if prime==1 & victim == 0
quietly eststo Control1: mean y_1 if prime==0  & victim == 1
quietly eststo Treatment1: mean y_1 if prime==1 & victim == 1

coefplot Control0 Treatment0, vertical ///
recast(bar) barwidth(0.25) xlab("") ciopts(recast(rcap)) citop citype(normal) ///
graphregion(color(white)) bgcolor(white) ///
ylab(, nogrid) scheme(s1mono) plotregion(style(none)) mlabel title("Non-victim", size(medium)) ///
saving("$results/victim0", replace) legend(label(1 "Control") label(3 "Treatment"))

coefplot Control1 Treatment1, vertical ///
recast(bar) barwidth(0.25) xlab("") ciopts(recast(rcap)) citop citype(normal) ///
graphregion(color(white)) bgcolor(white) ///
ylab(, nogrid) scheme(s1mono) plotregion(style(none)) mlabel title("Victim", size(medium)) ///
saving("$results/victim1", replace) legend(label(1 "Control") label(3 "Treatment"))

graph combine "$results/victim0" "$results/victim1", scheme(s1mono) rows(1) cols(2) xcommon ycommon ///
title("Average Support Special Seats by Prime Experiment and Prior Victimization", size(medsmall)) 

graph export "$results/prime_victim1.pdf", replace

** Other tables not used in paper. 

*Outcome 1 
reg y_1 prime, robust
outreg2 using "$results/T-test1.tex", label tex(frag) ctitle(Special seats) replace

reg y_1 prime area urprime, robust
outreg2 using "$results/T-test1.tex", label tex(frag) ctitle(Area) append

reg y_1 prime sex sexprime, robust
outreg2 using "$results/T-test1.tex", label tex(frag) ctitle(Sex) append

* Outcome 2 
reg y_2 prime, robust
outreg2 using "$results/T-test2.tex", label tex(frag) ctitle(Political parties) replace

reg y_2 prime area urprime, robust
outreg2 using "$results/T-test2.tex", label tex(frag) ctitle(Area) append

reg y_2 prime  sex sexprime, robust
outreg2 using "$results/T-test2.tex", label tex(frag) ctitle(Sex) append

* Outcome 3 
reg y_4 prime, robust
outreg2 using "$results/T-test3.tex", label tex(frag) ctitle(Vote support) replace

reg y_4 prime area urprime, robust
outreg2 using "$results/T-test3.tex", label tex(frag) ctitle(Area) append

reg y_4 prime  sex sexprime, robust
outreg2 using "$results/T-test3.tex", label tex(frag) ctitle(Sex) append

*Outcome 4
reg y_5 prime, robust
outreg2 using "$results/T-test4.tex", label tex(frag) ctitle(Accept result) replace

reg y_5 prime area urprime, robust
outreg2 using "$results/T-test4.tex", label tex(frag) ctitle(Area) append

reg y_5 prime sex sexprime, robust
outreg2 using "$results/T-test4.tex", label tex(frag) ctitle(Sex) append

 
** Robustness checks: 

* Now include pre-treatment outcome variable to increase precision: We use colconce4 as pre-treat. variable

clonevar colconce4R = colconce4  
lab var colconce4R "Government Guarantees pol. part. to demobilized FARC"
recode colespa1 (11/12=.)
clonevar colespa1R  = colespa1
lab var colespa1R "FARC form political party"

reg y_1 prime colconce4R colespa1R, robust
outreg2 using "$results/T-test0_ad.tex", label tex(frag) ctitle(Colprime1) replace
reg y_2 prime colconce4R colespa1R, robust
outreg2 using "$results/T-test0_ad.tex", label tex(frag) ctitle(Colprime2) append
reg y_4 prime colconce4R colespa1R, robust
outreg2 using "$results/T-test0_ad.tex", label tex(frag) ctitle(COLESPA6) append
reg y_5 prime colconce4R colespa1R, robust
outreg2 using "$results/T-test0_ad.tex", label tex(frag) ctitle(COLESPA8) append

* SEs clustered at the municipal level. 

reg y_1 prime, vce(cluster municipio_868)
outreg2 using "$results/T-test_cluster.tex", label tex(frag) ctitle("Seats for FARC") replace
reg y_2 prime, vce(cluster municipio_868)
outreg2 using "$results/T-test_cluster.tex", label tex(frag) ctitle("FARC Party") append
reg y_3 endors, vce(cluster municipio_868)
outreg2 using "$results/T-test_cluster.tex", label tex(frag) ctitle("Special Seats") append

* Political Knowledge and ideology.

* Interaction endors with ideology
clonevar ideol = l1
lab var ideol "Ideology"
gen ideolendors = l1 * endors
lab var ideolendors "Ideology X Endors."

* Interaction endors with pol. knowledge

****CAN'T USE THIS IT IS POST-TREATMENT
recode pol1 (5=.)
gen polknow = (pol1 == 1 | pol1 == 2)
lab var polknow "Interest in politics"
gen polknowendors = l1 * endors
lab var polknowendors "Politics X Endors."

reg y_3 endors ideol ideolendors, robust
outreg2 using "$results/Endors_interpret.tex", label tex(frag) ctitle("Special Seats") replace
reg y_3 endors polknow polknowendors, robust
outreg2 using "$results/Endors_interpret.tex", label tex(frag) ctitle("Special Seats") append


* Graphically 
quietly eststo Control0: mean y_3 if endors==0  & polknow == 0
quietly eststo Treatment0: mean y_3 if endors==1 & polknow == 0
quietly eststo Control1: mean y_3 if endors==0  & polknow == 1
quietly eststo Treatment1: mean y_3 if endors==1 & polknow == 1

coefplot Control0 Treatment0, vertical ///
recast(bar) barwidth(0.25)  ciopts(recast(rcap)) citop citype(normal) ///
graphregion(color(white)) bgcolor(white) ///
ylab(, nogrid) scheme(s1mono) plotregion(style(none)) mlabel title("A lot or Some Interest", size(medium)) ///
saving("$results/robust0", replace) legend(label(1 "Control") label(3 "Treatment"))

coefplot Control1 Treatment1, vertical ///
recast(bar) barwidth(0.25)  ciopts(recast(rcap)) citop citype(normal) ///
graphregion(color(white)) bgcolor(white) ///
ylab(, nogrid) scheme(s1mono) plotregion(style(none)) mlabel title("Little or None Interest", size(medium)) ///
saving("$results/robust1", replace) legend(label(1 "Control") label(3 "Treatment"))

graph combine "$results/robust0" "$results/robust1", scheme(s1mono) rows(1) cols(2) xcommon ycommon ///
title("Treatment Effect Endorsement Experiment by Interest in Politics", size(medsmall)) 

graph export "$results/robust.pdf", replace


*------------------------------------2.3: Dif in difs ------------------------------------

gen dd = prime * endors
lab var dd "Prime X Endorsement"

reg y_3 prime endors dd, robust
outreg2 using "$results/Difsindi.tex", label tex(frag) ctitle(colendorse) replace

preserve
	collapse (mean) y_3, by(endors prime)
	gen new = 0.2 if prime == 0 
	replace new = 0.8 if prime == 1
	twoway (connected y_3 new if endors == 0) (connected y_3 new if endors == 1), ///
	xlab("") ylab(3(0.25)5) scheme(s1mono) xline(0.5) ytitle("") ///
	legend(label(1 "Control Endors.") label(2 "Treatment Endors.")) xtitle("") ///
	title("", size(medium)) ///
	xlabel(0 " " 0.2 "Control Prime" 0.8 "Treatment Prime" 1" ") xmtick(0.2 0.8) saving("$results/did_graph.gph", replace)
	graph export "$results/did_graph.pdf", replace
restore

exit
/* End of do-file */

><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><

Notes:
1. Dataset dowloaded from Observatorio de la Democracia & LAPOP websites
2. Final version to post online
3.


Version Control: 8


